package solution._0000._0009;

/**
 * Created by chen_snow
 * Date: 2021/5/6 22:44
 * Description: 回文数
 */
public class Solution {
    public boolean isPalindrome(int x) {
        if (x < 0) {
            return false;
        }

        int num = 0;
        int temp = x;
        while (temp != 0) {
            num++;
            temp = temp / 10;
        }

        while (num > 1) {
            int big = (int) (x / (Math.pow(10, num - 1)));
            int small = x % 10;
            if (big != small) {
                return false;
            }

            x = (int) ((x - big * (Math.pow(10, num - 1))) / 10);
            num = num - 2;
        }

        return true;
    }
}
